<style lang="less">
@import "../../../styles/common.less";
@import "../../../styles/table.less";
</style>

<template>
    <div>
      <Card class="clearfix" style="padding-bottom: 16px">
        <p slot="title">
          在库实车
        </p>
        <Form label-position="left" :label-width="72">
          <Row :gutter="15">
            <i-col span="6">
              <FormItem label="关键字：">
                <Input v-model="modelData" placeholder="请输入车型关键字"/>
              </FormItem>
            </i-col>
            <i-col span="6">
              <FormItem label="指导价：">
                <Input v-model="guidanceprice" placeholder="请输入指导价"/>
              </FormItem>
            </i-col>
            <i-col span="6">
              <FormItem label="车架号：">
                <Input v-model="vin" placeholder="请输入车架号"/>
              </FormItem>
            </i-col>
            <i-col span="5" >
              <FormItem  label="主体列表：">
                <Select style="width:120px" v-model="partyName" filterable clearable>
                     <Option @click.native="setPartyUser(item)" v-for="(item,index) in partys" :value="item.name" :key="index" :label="item.name">{{ item.name }}</Option>
                </Select>
              </FormItem>
            </i-col>
            <i-col span="5" >
              <FormItem  label="人员名称：">
                <Select style="width:120px" v-model="realName" filterable clearable>
                     <Option  v-for="(item,index) in users" :value="item.realName" :key="index" :label="item.realName">{{ item.realName }}</Option>
                </Select>
              </FormItem>
            </i-col>
            <i-col span="6" >
              <FormItem label="车源省份：" >
                <Select  filterable label-in-value >
                  <Option @click.native="setArea(item)" v-for="(item,index) in areaList" :value="item.cityCode" :key="index" :label="item.cityName">{{ item.cityName }}</Option>
                </Select>
              </FormItem>
            </i-col>
            <i-col span="6" >
              <FormItem label="车源城市：" label-position="left">
                <Select  v-model="carLocation" filterable clearable>
                  <Option v-for="(item,index) in areaCityList" :value="item.cityName" :key="index" :label="item.cityName">{{ item.cityName }}</Option>
                </Select>
              </FormItem>
            </i-col>
            <i-col span="6">
              <Button type="success" @click="searchData" icon="ios-search" >搜索</Button>
            </i-col>
          </Row>
        </Form>
        <div class="btn-group-list">
          <Button  @click="addData" v-if="access.add" icon="ios-checkmark" style="width:90px;" type="primary">新增</Button>
        </div>
        <br>
        <div>
            <list-table refs="table1" v-model="tableData" :access="access" :table-data="tableData"></list-table>
        </div>
        <Page ref="pages" :total="itemTotal" show-total style="float: right; margin-top: 20px" @on-change="getList"></Page>
      </Card>
    </div>
</template>

<script>
import listTable from './components/listTable.vue'
import ajax from '../../../libs/axios.js'
export default {
    name: 'personalindex',
    components: {
        listTable
    },
    data () {
        return {
          kezu_testModelShow:false,
           statusValue: '',
           access:{
                edit: true, //控制编辑按钮显示
                func: true,
                remove: true,
                add: true
            },
            loginName: '',//用户名称
            modelData:'',
            guidanceprice:'',//指导价
            vin:'',//请输入车架号
            itemTotal: 0,
            tableData: [],
            partys:[],//企业集合
            partyId:'',//企业id
            partyName:'',//主体名称
            users:[],//当前企业下的人员
            userId:'',//用户的id
            realName:'',//人员名称
            carLocation:'',//车源所在地
            areaList:[],//车源所在地--省份
            areaCityList:[]//车源所在地--城市
        }
    },
    methods: {
        init () {
           this.$store.commit('setActiveName', 'realcarindex');
           this.getList(1)
           this.selectArea()
        },
        addData () {
          this.kezu_testModelShow = true;
            let argu = {
                id: 'add'
            }
            this.$router.push({
                name: 'addrealcar',
                params: argu
            })
        },
        searchData () {
            this.getList(1)
        },
        setPartyUser(obj){
            this.users = obj.users;
        },
        selectArea(){//获取区域信息
            let _that = this;
            let url = '/adminlogin/carsource/selectArea'
            let data = {
            }
            ajax.formRes(url, data).then(res => {
                _that.areaList = res.area;
            }).catch(res => {
                console.log('有错误信息')
                // fail
            })
        },
        setArea(obj){
            this.areaCityList = obj.citys;
        },
        getList (page) {
            let _that = this;
            let url = '/adminlogin/carsource/selectInfos'
            let data = {
                modelData: this.modelData,
                guidanceprice: this.guidanceprice,
                partyId:this.partyId,
                partyName:this.partyName,
                realName:this.realName,
                vin:this.vin,//车架号
                carLocation:this.carLocation,//
                type:2,
                pageSize: 10,
                pageNum: page
            }
            ajax.formRes(url, data).then(res => {
                _that.partys = res.partys
                _that.tableData = res.data;
                _that.itemTotal = res.count;
            })
                .catch(res => {
                    console.log('有错误信息')
                    // fail
                })
        }
    },
    mounted () {
        this.init()
    },
    activated() {
      this.init()
    },
}
</script>
